import {baseUrl} from "./config.js";

export function topList() {
	return new Promise(function(resolve,reject){
		
		uni.request({
			//请求地址
			url: `${baseUrl}/toplist/detail`, //http://localhost:3000/toplist/detail
			//请求方式
			method: 'GET',
			data: {},
			//成功之后的操作
			success: res => {
				//成功之后打印响应
				//console.log(res)
				//赋值
				let result=res.data.list
				//设置长度
				result.length=4,
				//封装数据
				resolve(result)
			},
			//失败之后的操作
			fail: () => {
		
			},
			//完成之后的操作
			complete: () => {
		
			}
		});
	})

}


//list页面接口方法  http://localhost:3000/playlist/detail?id=19723756
export function list(id){
	return uni.request({
		//请求地址
		url:`${baseUrl}/playlist/detail?id=${id}`,
		method:"GET"
	})	
}
//获取歌曲信息
//http://localhost:3000/song/detail?ids=347230
export function songDetail(id){
	return uni.request({
		//请求地址
		url:`${baseUrl}/song/detail?ids=${id}`,
		method:"GET"
	})	
}
//获取歌词信息
//http://localhost:3000/lyric?id=347230
export function songLyric(id){
	return uni.request({
		//请求地址
		url:`${baseUrl}/lyric?id=${id}`,
		method:"GET"
	})	
}
//播放歌曲url
//http://localhost:3000/song/url?id=347230
export function songUrl(id){
	return uni.request({
		//请求地址
		url:`${baseUrl}/song/url?id=${id}`,
		method:"GET"
	})	
}